package com.example.smartcity_poverty.ui.AllService.ActivityManAge

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import com.example.smartcity_poverty.logic.Repository
import com.example.smartcity_poverty.logic.model.ActivityManAge.HBanner
import com.example.smartcity_poverty.logic.model.ActivityManAge.HListModel
import com.example.smartcity_poverty.logic.model.ActivityManAge.HListUserAll

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *
 **/
class ManAgeViewModel : ViewModel() {

    /**
     * 获取轮播图
     */
    private val banner = MutableLiveData<String>().apply {
        postValue("获取轮播图")
    }
    val bannerList = ArrayList<HBanner.RowsBean>()
    val bannerLiveData = Transformations.switchMap(banner){
        Repository.getHBanner()
    }

    /**
     * 活动列表
     */
    private val hList = MutableLiveData<Int>()
    val hListList = ArrayList<HListModel.RowsBean>()
    val hLiveData = Transformations.switchMap(hList){ query ->
        Repository.getHList(query)
    }
    fun setHList(id: Int){
        hList.value = id
    }

    // 评论
    private val hListUserAll = MutableLiveData<Int>()
    val hListUserList = ArrayList<HListUserAll.RowsBean>()
    val hListUserLiveData = Transformations.switchMap(hListUserAll){ query ->
        Repository.getHListUserAll(query)
    }
    fun setHListUserAll(id: Int){
        hListUserAll.value = id
    }
}